package net.chasing.androidbaseconfig.util;

import androidx.annotation.NonNull;

import java.net.FileNameMap;
import java.net.URLConnection;

public class FileTypeUtils {

    public static String getMIMEType(@NonNull String fileName) {
        FileNameMap fileNameMap = URLConnection.getFileNameMap();
        String contentTypeFor = fileNameMap.getContentTypeFor(fileName);
        if (contentTypeFor != null)
            return contentTypeFor;
        else
            return "*/*"; //未知类型
    }
}
